﻿using System.Collections.Generic;
using System.Web.Mvc;
using LangMauViet.Models.Entity;
using LangMauViet.Models.Service;

namespace LangMauViet.Controllers
{
    public class NewsController : Controller
    {
        //
        // GET: /News/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult NewsDetail(long id)
        {
            NewsService ns = new NewsService();
            List<News> lnews = ns.GetDetailNews(id,"");
            List<News> lNews2 = ns.GetNews(lnews[0].CategoryId, 0, 0, 4);
            CategoryService cs = new CategoryService();
            List<HotItem> lhot = cs.GetHotItem(3);
            ViewData["listHot"] = lhot;
            ViewData["listNews"] = lnews;
            ViewData["listOtherNews"] = lNews2;

            //WEB
            List<News> lNewsHotWeb = ns.GetNews(0, 1, 0, 23);
            ViewData["lNewsHotWeb"] = lNewsHotWeb;
            List<News> nlistHotWeb = ns.GetNews(0, 0, 0, 24);

            ViewData["nlistHotWeb"] = nlistHotWeb;
            return View(lnews);
        }

        public ActionResult ViewNews(long id)
        {
            NewsService ns = new NewsService();
            List<News> lnews = ns.GetDetailNews(id, "");
            List<News> lNews2 = ns.GetNews(lnews[0].CategoryId, 0, 0, 4);
            CategoryService cs = new CategoryService();
            List<HotItem> lhot = cs.GetHotItem(3);
            ViewData["listHot"] = lhot;
            ViewData["listNews"] = lnews;
            ViewData["listOtherNews"] = lNews2;

            //WEB
            List<News> vlistNewsXemNhieu = ns.GetNews(0, 1, 0, 20); //1: download
            ViewData["vlistNewsXemNhieu"] = vlistNewsXemNhieu;
            List<News> vlistNewsNewWeb = ns.GetNews(0, 0, 0, 7); //0: crate date
            ViewData["vlistNewsNewWeb"] = vlistNewsNewWeb;
            List<News> vlistNoibat = ns.GetNews(0, 2, 0, 6); //3: position ( éo hiểu là gì)
            ViewData["listNewsNoibat"] = vlistNoibat;

            return View();
        }

    }
}
